package com.res.controller;

import com.res.entity.Computer;
import com.res.entity.Readroom;
import com.res.service.ReadRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("readroom")
public class ReadRoomController {
@Autowired
    private ReadRoomService readRoomService;

@GetMapping
    public Map<String,Object> getAll(){
    Map<String,Object> map=new HashMap<String, Object>();
    List<Readroom> allReadRoom = readRoomService.findAllReadRoom();
    long l = readRoomService.countReadRoom();
    map.put("data",allReadRoom);
    map.put("code",0);
    map.put("count",l);
    map.put("msg","");
    return  map;
}
    @PostMapping
    public Integer addComputer(Readroom  readroom){
        return readRoomService.addReadRomm(readroom);
    }

    @DeleteMapping
    public Integer deleteComputer(Integer rid ){
        return readRoomService.deleteReadRoom(rid);
    }
}
